<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线点餐系统管理平台</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/foodlist.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/invalid.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/jquery_dialog.css" type="text/css" media="screen" />
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/facebox.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.date.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery_dialog.js"></script> 
<script type="text/javascript">

	function goPage(toPage){
		var frm = document.getElementById("frmPage");
		frm["pageObj.currPage"].value=toPage;
		frm.submit();
	}
	function delOneFoodType(obj,toPage,foodTypeId){
	  if(!confirm("您确定要删除此商品？")){
	     return;
	  }
	 obj.href="foodTypeManager!del?pageObj.currPage="+toPage+"&foodTypeIds="+foodTypeId;	 
	}
	
	function delMoreFoodType(obj,toPage){
		if(!confirm("您确定要删除商品？")){
		     return;
		}	  
	   var foodfoodTypeIdIds_list=$("input[name='foodTypeId']:checked");
	   if(foodfoodTypeIdIds_list.length==0){
	   	 return;
	   }
	   var foodTypeIds="";
	   for(var i=0;i<foodfoodTypeIdIds_list.length;i++){
	  	 foodTypeIds+=(i<foodfoodTypeIdIds_list.length-1)?foodfoodTypeIdIds_list[i].value+",":foodfoodTypeIdIds_list[i].value;
	   }
	  obj.href="foodTypeManager!del?pageObj.currPage="+toPage+"&foodTypeIds="+foodTypeIds;	 
	};
	//显示修改
	function showUpdate(index){
	   $("#name"+index).removeAttr("style").removeAttr("readonly");
	   $("#c_z_"+index).hide();
	   $("#b_q_"+index).show();
	}
	//取消显示
	function closeUpdate(index,name){
	   $("#name"+index).attr("style","background-color:transparent;border:none").attr("readonly","true").val(name);
	   $("#c_z_"+index).show();
	   $("#b_q_"+index).hide();
	}
 //保存
 function save(index,name,id){
	 var url="foodTypeManager!updateFoodType";
	 $.post(url,{"foodType.name": name,"foodType.id":id},function(datea){
	  closeUpdate(index,name);
	 });
 }
</script>
</head>
  <body>
  <%-- 加载左边菜单 --%>
  <s:include value="../main/left.jsp?mid=m24"></s:include>
  
  <div class="clear"></div>
  <div id="main-content">
  
   <!-- Box Content -->
   <div class="content-box">
   
    <!-- Box Header -->
		<div class="content-box-header">
	    <h3>商品列表</h3>
	    <div class="clear"></div>
  	</div>
  	<!-- End Box header -->
  
  	<!-- Table Content -->
  	<div class="tab-content">
  		<table>
  			<thead>
  				<tr>
  			<th><input class="check-all" type="checkbox" /></th>
  			<th>编号</th>
            <th>商品类别</th>
            <th>操作</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <td colspan="3">
              <div class="bulk-actions align-left"><a class="button" href="#" onclick="delMoreFoodType(this,${pageObj.currPage})">删&nbsp;&nbsp;除</a></div>
              <div class="pagination">
              <s:form action="foodTypeManager!list" namespace="/admin" id="frmPage">
              <s:textfield name="pageObj.currPage" size="1"/>/${pageObj.allPages }页，每页显示${pageObj.rows }行，共${pageObj.allRows }行
							<input type="submit" value="GO!"/>
							
							<a href="javascript:goPage('1')">&laquo; 首页</a>
							<s:if test="pageObj.hasPrePage">
							<a href="javascript:goPage('${pageObj.prePage }')">&laquo; 上一页</a>
							</s:if>
							<s:if test="pageObj.hasNextPage">
							<a href="javascript:goPage('${pageObj.nextPage }')">下一页 &raquo;</a>
							</s:if>
							<a href="javascript:goPage('${pageObj.allPages }')">尾页 &raquo;</a>
							</s:form>
              </div>
              <!-- End .pagination -->
              <div class="clear"></div>
            </td>
          </tr>
        </tfoot>
        <tbody>
        <s:iterator value="pageObj.results" var="temp" status="status">
	  		<tr>
	  		  <td width="20%"><input type="checkbox" name="foodTypeId" value="${temp.id }"/></td>
  			 <td  width="20%">
  			  	${status.index+1}
  			  </td>
  			  <td width="50%">
  			   <div style="width:60px;heigth:30px;">	<input id="name${status.index+1}" type='text' value='${temp.name}' style="background-color:transparent;border:none" readonly/><pan></pan></div>
  			  
  			  </td>
  			  <td width="10%">
  			          <div style="display:" id="c_z_${status.index+1}">
						<a href="#" onclick="showUpdate(${status.index+1})" title="编辑"><img src="${pageContext.request.contextPath }/admin/images/icons/pencil.png" alt="编辑" /></a> 
						<a href="#" title="删除" onclick="delOneFoodType(this,${pageObj.currPage},${temp.id })"><img src="${pageContext.request.contextPath }/admin/images/icons/cross.png" alt="删除" /></a> 
					</div>
					<div style="display:none" id="b_q_${status.index+1}">
					  <a href="###" onclick="save(${status.index+1},'${temp.name }','${temp.id }')">保存</a> <a href="###" onclick="closeUpdate(${status.index+1},'${temp.name}')">取消</a>
					</div>
				</td>
	  		</tr>
		  	</s:iterator>
        </tbody>
			</table>
     </div>
     <!-- End Table Content -->
     
   </div>
   
   <!-- End Box Content -->
   
  <div class="clear"></div>
  <%-- 加载底部 --%>
  <s:include value="../main/footer.jsp"></s:include>
  </div>
  </body>
</html>
